// 权限模块所有请求

import request from '@/utils/request'
// 获取权限列表
export function getPermissionList() {
  return request({
    url: '/permission/menu',
    method: 'GET'
  })
}
// 添加菜单
export function addPermissionList(data) {
  return request({
    url: '/permission/menu',
    method: 'POST',
    data
  })
}
// 通过id获取权限
export function getPermissionById(id) {
  return request({
    url: `/permission/menu/${id}`,
    method: 'GET'
  })
}
export function changePermissionById(id, val) {
  return request({
    url: `/permission/menu/${id}/${val}`,
    method: 'GET'
  })
}
// 通过id编辑权限
export function editPermissionById(data) {
  return request({
    url: `/permission/menu/${data.id}`,
    method: 'PUT',
    data
  })
}
// 通过id删除权限
export function delPermissionById(id) {
  return request({
    url: `/permission/menu/${id}`,
    method: 'DELETE'
  })
}
// 添加权限
export function addMenu(data) {
  return request({
    url: '/permission/menu',
    method: 'POST',
    data
  })
}
// 获取所有权限角色
export function getPermissionRoles(params) {
  return request({
    url: '/permission/role',
    method: 'GET',
    params
  })
}
// 搜索权限角色
export function getPersonPermission(params) {
  return request({
    url: '/permission/role',
    method: 'GET',
    params
  })
}
// 通过id获取权限角色信息
export function getPersonById(id) {
  return request({
    url: `/permission/role/${id}`,
    method: 'GET'
  })
}
// 通过id删除权限角色
export function delPersonById(id) {
  return request({
    url: `/permission/role/${id}`,
    method: 'DELETE'
  })
}
// 添加权限角色
export function addPermissionRole(data) {
  return request({
    url: '/permission/role',
    method: 'POST',
    data
  })
}
// 编辑权限角色
export function editPersonPermission(data) {
  return request({
    url: `/permission/role/${data.id}`,
    method: 'PUT',
    data
  })
}
